package org.apache.commons.codec.language.bm;

import java.io.InputStream;
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;

public class a {
    public static final b a = new b() {
        public String toString() {
            return "NO_LANGUAGES";
        }
    };
    public static final b b = new b() {
        public String toString() {
            return "ANY_LANGUAGE";
        }
    };
    private static final Map c = new EnumMap(d.class);
    private final Set d;

    static {
        for (d dVar : d.a()) {
            c.put(dVar, a(b(dVar)));
        }
    }

    private a(Set set) {
        this.d = set;
    }

    public static a a(String str) {
        Set hashSet = new HashSet();
        InputStream resourceAsStream = a.class.getClassLoader().getResourceAsStream(str);
        if (resourceAsStream == null) {
            throw new IllegalArgumentException("Unable to resolve required resource: " + str);
        }
        Scanner scanner = new Scanner(resourceAsStream, "UTF-8");
        Object obj = null;
        while (scanner.hasNextLine()) {
            String trim = scanner.nextLine().trim();
            if (obj != null) {
                if (trim.endsWith("*/")) {
                    obj = null;
                }
            } else if (trim.startsWith("/*")) {
                obj = 1;
            } else if (trim.length() > 0) {
                hashSet.add(trim);
            }
        }
        return new a(Collections.unmodifiableSet(hashSet));
    }

    public static a a(d dVar) {
        return (a) c.get(dVar);
    }

    private static String b(d dVar) {
        return String.format("org/apache/commons/codec/language/bm/%s_languages.txt", new Object[]{dVar.b()});
    }

    public Set a() {
        return this.d;
    }
}
